import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

import database.ApprovingComputerizedTestGrade;


public class StatisticInformationTest extends TestCase {

	ApprovingComputerizedTestGrade a;
	
	
	public StatisticInformationTest(String name)
	{
		super(name);
	}
	
	@Before
	public void setUp() throws Exception {
		this.a = new ApprovingComputerizedTestGrade();
	}

	@Test
	public void testCalculateAVG() {
		float result = a.calculateAVG(generateList1());
		float expected = 100;
		//check if average of list that all grades are 100, is 100
		assertEquals(expected, result);
		
		//check if average of list that all grades are 0,10,20,30,40, is 20
		result = a.calculateAVG(generateList2());
		expected = 20;
		assertEquals(expected, result);
		
		//fail("Not yet implemented");
	}

	@Test
	public void testCalculateMedian() {
		int result = a.calculateMedian(generateList1());
		int expected = 100;
		
		//check if median of list that all grades are 100, is 100
		assertEquals(expected, result);
		
		//check if median of list that all grades are 0,10,20,30,40, is 20
		result = a.calculateMedian(generateList2());
		expected = 20;
		assertEquals(expected, result);
		
		//check if median of list that all grades are 80,90,65,100 is 90
		result = a.calculateMedian(generateList3());
		expected = 90;
		assertEquals(expected, result);
		
		//check if list of grades is empty
		List<Integer> list = null;
		assertNull(list);
		
		//check if list of grades is not empty
		list = generateList1();
		assertNotNull(list);
		
		//fail("Not yet implemented");
	}
	
	
	
	public List<Integer> generateList1()
	{
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i< 5; i++)
			list.add(100);
		
		return list;
	}
	
	public List<Integer> generateList2()
	{
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i< 5; i++)
			list.add(i*10);
		
		return list;
	}
	
	public List<Integer> generateList3()
	{
		List<Integer> list = new ArrayList<>();
		list.add(80);
		list.add(90);
		list.add(65);
		list.add(100);
		
		return list;
	}
	
	
	

}
